﻿using System;

namespace RockCorn
{
    public class WelcomeScreen
    {
        int visibleConsoleRows;
        int visibleConsoleCols;

        string message = "LEVEL 1";

        string gameName = @"
###           #       ####              
# #           #      ##                 
# #   ##   ## # ##   #      ##  ### ### 
##   #  # #   ###    #     #  # #   # # 
# #  #  # #   ###    ##  # #  # #   # # 
#  #  ##   ## # ##    ####  ##  #   # # 
";

        public string GameName
        {
            get { return gameName; }
        }

        public string Message
        {
            get { return message; }
        }

        public WelcomeScreen(int visibleConsoleRows, int visibleConsoleCols)
        {
            this.visibleConsoleCols = visibleConsoleCols;
            this.visibleConsoleRows = visibleConsoleRows;
        }

        public void PrintMessage()
        {
            string delimiter = new string('*', visibleConsoleCols);
            Console.SetCursorPosition(0, 0);

            // +1 ot +2 because of rendering bugs in the Console
            Console.WindowHeight = visibleConsoleRows + 2;
            Console.WindowWidth = visibleConsoleCols + 1;
            Console.BufferHeight = Console.WindowHeight;
            Console.BufferWidth = visibleConsoleCols + 1;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(delimiter);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(Message);
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(delimiter);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(GameName);
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(delimiter);

            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.WriteLine("\n\n\n\n\n\n press \"Enter\" to start GAME");
            Console.ResetColor();
            Console.ReadKey();
            this.PrintInformation();
        }

        private void PrintInformation()
        {
            Console.Clear();
            string delimiter = new string('*', visibleConsoleCols);

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(delimiter);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(GameName);
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(delimiter);
            Console.WriteLine("{0,15}", "CONTROLS");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(delimiter);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("{0,10} - left", "a");
            Console.WriteLine("{0,10} - right", "d");
            Console.WriteLine("{0,10} - shoot", "Spacebar");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(delimiter);
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("{0,10} - block", "#");
            Console.WriteLine("{0,10} - exploding block", "*");
            Console.WriteLine("{0,10} - unpassable block", "X");
            Console.WriteLine("{0,10} - gift block", (char)164);
            Console.WriteLine("{0,10} - gift", "+");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(delimiter);
            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.WriteLine("\n\n press \"Enter\" to start GAME");
            Console.ResetColor();
            Console.Read();
            Console.Clear();
        }

    }
}
